﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="1.aspx.cs" Inherits="_1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    
    
    <script type="text/javascript">
       
        ////定义要判断的字符串
        //var str = "afsfd(bcd)asfasfsad(def)asdfsadf";
        ////定义正则表达式对象，\表示转义字符,原点表示任意字符，+表示出现次数至少1次，igm表示忽略大小写，且全局匹配
        //pattern = new RegExp("\\((.| )+?\\)", "igm");
        ////取出匹配正则表达式的内容
        //alert(str.match(pattern));
        function zyc(parameters) {
            var strResult = '';
            var str = "客人来电咨询：（客户问题+客户需求），回电号码（跟客人确认需回电的号码），用户姓氏（）";
            //var str = "客人来电要求恢复订单；用户姓氏（），联系电话（）";
            str = str.replace(/（/g, "(");
            str = str.replace(/）/g, ")");
            str =str. replace(" ", "，");
            var array1 = str.split("(");
            if (array1.length == 1) {
                alert("null");
                strResult = array1[0];
            }
            for (var i = 0; i < array1.length; i++) {
                var index = array1[i].indexOf(")");
                if (index > -1) {
                    if (index != 0) {

                        if (array1[i].split(")")[0].indexOf("+") > -1) {
                            strResult +=
                                '<textarea name="textarea" id="textarea" style="overflow-y: hidden;height:20px"onpropertychange="this.style.posHeight = this.scrollHeight + \"px\";" placeholder="' + array1[i].split(")")[0] + '"></textarea> ';
                        } else {


                            strResult +=
                                '<input type="text" placeholder="' + array1[i].split(")")[0] + '"></textarea> ';
                        }
                        strResult += array1[i].split(")")[1];
                    } else {
                        strResult +=
                            '<input type="text" placeholder=""> ';
                        //var aaa = array1[i].split(")").length;
                        //alert("num"+aaa);
                        if (array1[i].split(")").length > 1) {
                            strResult += array1[i].split(")")[1];
                        }
                    }
                } else {
                    strResult += array1[i];
                }
            }
            alert(strResult);
            document.getElementById("zyc").innerHTML = strResult;
        }

        function zyc11(parameters) {
            document.getElementById("zyc").innerHTML = yy();
        }


        function yy() {
            debugger;
            var strResult = '';
            var str = "客人来电反馈：（客户问题+客户需求），回电号码（跟客人确认需回电的号码），用户姓氏（）";
            str = str.replace(/（/g, "(");
            str = str.replace(/）/g, ")");
            str = str.replace(" ", "，");
            var array1 = str.split("(");
            if (array1.length == 1) {
                return '<span class="textContent">' + array1[0] + ' </span>';
            }
            for (var i = 0; i < array1.length; i++) {
                var index = array1[i].indexOf(")");
                if (index > -1) {
                    if (index != 0) {
                        if (array1[i].split(")")[0].indexOf("+") > -1) {
                            strResult +=
                                    '<textarea class="textContent" name="textarea"  style=" width:335px;" placeholder="' + array1[i].split(")")[0] + '"></textarea> ';
                        } else {
                            strResult +=
                              '<input type="text" class="textContent" placeholder="' + array1[i].split(")")[0] + '"> ';
                        }

                        strResult += '<span class="textContent">' + array1[i].split(")")[1] + ' </span>';
                    } else {
                        strResult +=
                            '<input type="text" class="textContent" placeholder=""> ';
                        if (array1[i].split(")").length > 1) {
                            strResult += '<span class="textContent">' + array1[i].split(")")[1] + ' </span>';
                        }
                    }
                } else {
                    strResult += '<span class="textContent">' + array1[i] + ' </span>';
                }
            }
            return strResult;
        }

        function zz(parameters) {
            debugger;
            var oo = document.getElementsByClassName("textContent");
            var conNum = document.getElementsByClassName("textContent").length;
            var content = '';
            for (var i = 0; i < conNum; i++) {
                var tagname = oo[i].tagName;
                if (tagname == "INPUT" || tagname == "TEXTAREA") {
                    content += oo[i].value;
                } else if (tagname == "SPAN") {
                    content += oo[i].innerHTML;
                }
            }
            alert(content);
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <span class="default_reply_cont">
  
  <p style="width:430px;margin-left:10px;padding-bottom:5px">
   <div id="zyc"></div>
    <span class="spanValid" id="spanContent">43</span>/400
  </p>
        <%--<textarea  ></textarea>--%>
        
        <%--<textarea name="textarea" id="textarea" style='overflow-y: hidden;height:20px' onpropertychange="this.style.height = this.scrollHeight + 'px';" oninput="this.style.height = this.scrollHeight + 'px';"></textarea>--%>
 </span>
        
    </div>
        <input type="button" value="测试" onclick="zyc11();"/>
          <input type="button" value="测试2" onclick="zz();"/>
    </form>
</body>
</html>
